package com.fingerth.crawler.utils

import android.os.Build
import android.view.View
import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.RelativeLayout
import androidx.constraintlayout.widget.ConstraintLayout
import com.fingerth.crawler.utils.stati.S
import com.google.android.material.appbar.CollapsingToolbarLayout

class SBarUtils {
    fun setBarHeight(view: View) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            when (view.parent) {
                is LinearLayout -> view.layoutParams = LinearLayout.LayoutParams(-1, S.getStatusBarHeight(view.context))
                is FrameLayout -> view.layoutParams = FrameLayout.LayoutParams(-1, S.getStatusBarHeight(view.context))
                is RelativeLayout -> view.layoutParams = RelativeLayout.LayoutParams(-1, S.getStatusBarHeight(view.context))
                is ConstraintLayout -> view.layoutParams = ConstraintLayout.LayoutParams(-1, S.getStatusBarHeight(view.context))
                is CollapsingToolbarLayout -> view.layoutParams = CollapsingToolbarLayout.LayoutParams(-1, S.getStatusBarHeight(view.context))
            }
        }

    }
}